<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>{$webTitle?:''}-登录</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="__LAYUI__/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="__LAYUI__/adminui/dist/css/admin.css" media="all">
		<link rel="stylesheet" href="__LAYUI__/adminui/dist/css/login.css" media="all">
	</head>
	<body>
		<div class="layadmin-user-login layadmin-user-display-show">
			<div class="layadmin-user-login-main" style="">
				<div class="layadmin-user-login-box layadmin-user-login-header">
					<h2>{$webTitle?:''}</h2>
				</div>
				<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
						<input type="text" name="username" value="{$userName?:''}" placeholder="请输入账号"
							class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
						<input type="password" name="password" placeholder="请输入密码" lay-affix="eye" class="layui-input">
					</div>
					<div class="layui-form-item">
						<div class="layui-input-wrap">
							<div id="slider"></div>
						</div>
					</div>
					<div class="layui-form-item">
						<input type="checkbox" name="remember" {notempty name="$userName" }checked{/notempty}
							title="记住账号">
					</div>
					<div class="layui-form-item">
						<button class="layui-btn layui-btn-fluid login-btn" lay-submit lay-filter="login-submit"> 登录
						</button>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
<script src="__LAYUI__/layui/layui.js"></script>
<script src="__LAYUI__/layui/js/notify.js"></script>
<script src="__LAYUI__/layui/js/sliderVerify.js"></script>
<script>
	layui.use(["layer", "jquery", "form", "sliderVerify"], function() {
		var layer = layui.layer;
		var $ = layui.jquery;
		var form = layui.form;
		var sliderVerify = layui.sliderVerify;
		var slider = sliderVerify.render({
			elem: "#slider"
		})
		// 此处可执行 Ajax 等操作
		form.on("submit(login-submit)", function(data) {
			$(".login-btn").text("正在登录").attr("disabled", true);
			if (slider.isOk()) { //滑动验证
				data.field.verify = true;
			} else {
				data.field.verify = "";
			}
			$.ajax({
				url: "{:url('login/index')}",
				data: data.field,
				type: "post",
				success: function(res) {
					if (res.code == 0) {
						notify.success(res.msg);
						setTimeout(function() {
							location.href = "/myadmin";
						}, 1000)
					} else {
						setTimeout(function() {
							notify.error(res.msg);
							if (data.field.verify == true) {
								slider.reset(); //重置滑动验证
							}
							$(".login-btn").text(" 登录 ").attr("disabled", false);
						}, 1000)
					}
				}
			});
			return false;
		});
	});
</script>